import java.lang.System;

/**
 * 选择排序，从小到大
 * 
 */
public class SelectionSort {

    public void solution(T[] nums) {
        int N = nums.length;
        for (int i = 0; i < N - 1; i++) {
            int min = i;
            for (int j = i + 1; j < N; j++) {
                if (nums[j] < nums[min]) {
                    min = j;
                }
            }
            swap(nums, i, min);
        }
    }

    public static void main(String[] args) {
        int[] nums = {1,3,6,4,8};
        System.out.println(new SelectionSort().solution(nums));
    }
}
